package com.dfs.parent.service.fallback;

import com.dfs.parent.common.core.domain.Result;
import com.dfs.parent.service.dto.ProductDTO;
import com.dfs.parent.service.feign.ProductFeignClient;
import com.dfs.parent.service.vo.ProductVO;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class ProductFeignClientFallbackFactory implements FallbackFactory<ProductFeignClient> {

    @Override
    public ProductFeignClient create(Throwable throwable) {
        System.out.println(throwable.getMessage());
        throwable.printStackTrace();

        System.out.println(throwable.getClass().getSimpleName());
        System.out.println("======000000=++++++++========");

        return new ProductFeignClient(){
            @Override
            public Result<ProductVO> reduceCount(ProductDTO productDTO) {

                return Result.fail("获取==失败:" + throwable.getMessage());
            }

            @Override
            public Result<String> config() {
                return Result.fail("22222");
            }
        };
    }
}
